package convertutil

import (
	"github.com/cihub/seelog"
	"time"
)

func ParseStandardDatePattern(timeStr string) *time.Time {
	time, err := time.Parse("2006-1-2 15:04:05", timeStr)
	if err != nil {
		seelog.Errorf("fail to time.Parse, dateStr=%s, err:%v", timeStr, err)
	}
	return &time
}

func ParseChinaDatePattern(timeStr string) *time.Time {
	time, err := time.Parse("2006年01月02日 15:04:05", timeStr)
	if err != nil {
		seelog.Errorf("fail to time.Parse, dateStr=%s, err:%v", timeStr, err)
	}
	return &time
}

func ParseDataStandSerialPattern(timeStr string) *time.Time {
	time, err := time.Parse("20060102150405", timeStr)
	if err != nil {
		seelog.Errorf("fail to time.Parse, dateStr=%s, err:%v", timeStr, err)
	}
	return &time
}

func FormatStandardDate(t time.Time) string {
	// yyyy-MM-dd HH:mm:ss
	return t.Format("2006-01-02 15:04:05")
}

func FormatDateChinaDate(t time.Time) string {
	// yyyy年MM月dd日 HH:mm:ss
	return t.Format("2006年01月02日 15:04:05")
}

func FormatDateyyyyMMddHHmmss(t time.Time) string {
	return t.Format("20060102150405")
}
